package com.caoheng.core.enums;

import java.util.Optional;

public enum ResultEnum {
    OK_200(200,"success"),
    ERROR_500(500,"服务器内部异常"),
    ERROR_400(400,"参数错误"),
    ERROR_403(403,"非法请求")
    ;
    private int type;

    private String tip;

    ResultEnum(int type,String tip){
        this.type = type;
        this.tip = tip;
    }

    public static Optional<ResultEnum> get(int type){
        for (ResultEnum e : values()){
            if(e.type == type){
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }

    public int getType() {
        return type;
    }

    public String getTip() {
        return tip;
    }
}
